package com.jinmdz.fmis.api.rec.controller;

import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.api.rec.model.recdispatchcar.RecDispatchCarData;
import com.jinmdz.fmis.api.rec.service.DispatchCarService;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.model.recinfo.RecInfoDispatchSearch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhanglr
 * @date 2020-6-11 14:02
 */
@Api(description = "车辆调度电话接运信息相关接口")
@RestController()
@RequestMapping("/rec/dispatch-car/")
public class DispatchCarController extends BaseController {

    @Resource
    private DispatchCarService dispatchCarService;

    /**
     * 加载车辆调度信息列表dispatch_car表中
     *
     * @param
     * @return
     * @author ZhangLiRui
     * @date 2020-6-11 14:55
     */
    @ApiOperation(value = "加载车辆调度信息列表dispatch_car表中", notes = "通过条件加载车辆调度信息")
    @PostMapping("load-dispatch-car-all")
    public BaseResult loadDispatchCarAll(@RequestBody RecInfoDispatchSearch data) {

        return resultHandler(data, userItem -> dispatchCarService.loadDispatchCarAll(userItem, data));
    }

    /**
     * 保存车辆调度信息到dispatch_car表中
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-19 17:22
     */
    @ApiOperation(value = "保存接运调度信息到rec_dispatch_car表中", notes = "保存接运调度信息到rec_dispatch_car表中")
    @PostMapping("save-dispatch-car")
    public BaseResult saveDispatchCar(@RequestBody RecDispatchCarData data) {
        return resultHandler(data, userItem -> dispatchCarService.saveDispatchCar(userItem, data));
    }

    /**
     * 从dispatch_car表中删除指定id的调度车辆信息
     *
     * @param
     * @return
     * @author GaoXiangLiang
     * @date 2020-6-11 11:42
     */
    @ApiOperation(value = "从dispatch_car表中删除指定id的调度车辆信息", notes = "从dispatch_car表中删除指定id的调度车辆信息")
    @PostMapping("delete-rec-info-with-id")
    public BaseResult deleteRecInfowithId(@RequestBody IdVersionData data) {
        return resultHandler(data, userItem -> dispatchCarService.deleteRecDispatchCarwithId(userItem, data));
    }


}
